package producerandconsumer;

public class Test {

    public static void main(String[] args) {
        Pot pot = new Pot();//创建锅对象，有限缓冲区。

        Producer mother = new Producer(pot);
        Consumer bigSon = new Consumer(pot,"大林");
        Consumer smallSon = new Consumer(pot,"小林");

        Thread motherThread = new Thread(mother);
        Thread bigSonThread = new Thread(bigSon);
        Thread smallSonThread = new Thread(smallSon);

        motherThread.start();
        bigSonThread.start();
        smallSonThread.start();

        try{
            motherThread.join(); //等待妈妈线程结束
            bigSonThread.join(); //等待大儿子线程结束
            smallSonThread.join(); //等待小儿子线程结束
        }catch(Exception ex){
            ex.printStackTrace();
        }
        pot.showResult();
    }
}
